varying vec2 vUv;
uniform float time;
uniform float offset;
uniform bool lineShow;
uniform vec3 lineColor;
uniform float lineOpacity;
uniform vec3 startColor;
uniform float startOpacity;
uniform vec3 endColor;
uniform float endOpacity;
uniform float lineLength;
void main() {
  float start = time * 0.0005 + offset;
  start = fract(start) * (1.0 + lineLength) - lineLength;
  float end = start + lineLength;
  float offset = end - vUv.x;
  if(offset < 0.0 || offset > lineLength) {
    if(lineShow) {
      gl_FragColor = vec4(lineColor, lineOpacity);
    } else {
      discard;
    }
  } else {
    float intensity = 0.1;
    intensity = 1.0 - abs(offset / lineLength);
    gl_FragColor = vec4(vec3(mix(endColor, startColor, intensity)), mix(endOpacity, startOpacity, intensity));
  }
}